package com.yanqu.road.server.cmd.player;

import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.pb.player.PlayerProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_CROSS_WATCH_PLAYER, desc = "跨服到拜访玩家信息")
public class CrossWatchPlayerCmd extends CrossCommand {
    private long userId;
    private long watchServerId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        PlayerProto.WatchPlayerReqMsg reqMsg = PlayerProto.WatchPlayerReqMsg.parseFrom(packet.getBytes());
        userId = packet.getPlayerId();
        watchServerId = reqMsg.getServerId();
        PlayerProto.CrossWatchPlayerReqMsg.Builder msg = PlayerProto.CrossWatchPlayerReqMsg.newBuilder();
        msg.setUserId(userId);
        msg.setServerId(serverId);
        msg.setWatchUserId(reqMsg.getUserId());
        msg.setWatchServerId(reqMsg.getServerId());
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(Protocol.S_CROSS_TO_WATCH_PLAYER, msg);
        MessageHelper.sendPacket(watchServerId, reqMsg.getUserId(), pbMsg);
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

    }

    @Override
    public void sendData() {

    }
}
